﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DataControl;
using System.Data;
using System.Text;

namespace ATW.MT.BUS
{
    public class bus_D_Currency
    {
        DataAccess da = null;
        public bus_D_Currency()
        {
            da = new DataAccess();
        }

        public DataTable CurrencyPagerQuery(string strDiName,  int page, int pagesize)
        {
            StringBuilder sql = new StringBuilder();
            sql.Append(@"select t1.*
                        from D_Currency t1 
                        where 1=1");
            if (!String.IsNullOrEmpty(strDiName))
            {
                sql.Append(" and t1.dcName like '%" + strDiName + "%'");
            }


            return da.PageSize(sql.ToString(), page, pagesize, "DCID");
            
        }

        /// <summary>
        /// 新增子项
        /// </summary>
        /// <param name="account"></param>
        /// <param name="pwd"></param>
        /// <param name="level_class"></param>
        /// <returns></returns>
        public int AddCurrency(string strName, decimal delRate)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendFormat(@"insert into D_Currency(rate,dcName) values({0},'{1}')",
                delRate, strName);
            return da.ExcuteNoQuery(sql.ToString());
        }

        /// <summary>
        /// 修改子项
        /// </summary>
        /// <param name="account"></param>
        /// <param name="pwd"></param>
        /// <param name="level_class"></param>
        /// <returns></returns>
        public int ModifyItem(string strDCID, string strName, decimal delRate)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendFormat(@"update D_Currency set dcName='{0}',rate={1} where DCID={2}",
                strName, delRate, strDCID);
            return da.ExcuteNoQuery(sql.ToString());
        }

        public DataTable SelectItem(string strId)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendFormat(@"select * from  D_Currency where DCID='" + strId + "'");
            return da.ExecuteDataTable(sql.ToString());
        }
    }
}